using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace teste.Models.Mapping
{
    public class MODELOMap : EntityTypeConfiguration<MODELO>
    {
        public MODELOMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Descricao)
                .IsRequired()
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("MODELO");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Codigo).HasColumnName("Codigo");
            this.Property(t => t.Descricao).HasColumnName("Descricao");
            this.Property(t => t.Marca_Id).HasColumnName("Marca_Id");

            // Relationships
            this.HasOptional(t => t.MARCA)
                .WithMany(t => t.MODELOes)
                .HasForeignKey(d => d.Marca_Id);

        }
    }
}
